<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
{% load staticfiles %}
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <title>修改个人信息</title>
    <link rel="stylesheet" type="text/css" href="{% static 'css/personal.css' %}"/>
    <script type="text/javascript" src="{% static 'js/personal.js' %}"></script>

</head>
<body>

<div class="banner">
    <input type="button" class="exit" value="退出">
    <input type="button" class="user" value="用户">
</div>

<div class="middle">

    <form name="user_s" id="data" action="{% url 'personal' %}" method="post"
          onsubmit="return validateForm()">{% csrf_token %}
        <div class="middle_re">

            <div class="Account">
                <h3>Account</h3>
                <h5>账&nbsp&nbsp户:&nbsp&nbsp&nbsp<label><input id="username_per" name="username_per"
                                                              value="{{ username1 }}" type="text" class="account"
                                                              placeholder="" readonly unselectable="on"></label></h5>
                <h5>昵&nbsp&nbsp称:&nbsp&nbsp&nbsp<input name="nickname" id="nickname" value="{{ nickname }}" type="text"
                                                       class="name" placeholder="输入昵称"></h5>
                <h5>性&nbsp&nbsp别:&nbsp&nbsp&nbsp<input name="gender" id="gender" value="{{ gender }}" type="sex"
                                                       class="sex" placeholder="输入性别 男/女" maxlength="1"></h5>
                <h5>手机号码:<input name="mobile" type="text" id="mobile" value="{{ mobile }}" class="number"
                                placeholder="请输入联系电话<必填字段>" maxlength="11"></h5>
                <h5>地&nbsp&nbsp址:&nbsp&nbsp&nbsp<input name="address" id="address" value="{{ address }}" type="text"
                                                       class="address" placeholder="请输入地址"></h5>
                <input type="hidden" id="password_per" name="password_per" value="{{ password1 }}">
            </div>
            <hr size=450px width="1" color="#999999">
            <div class="Trading">
                <h3>Trading_Account</h3>
                <h5><p style="margin-left:20px">*</p>BrokerID:<input id="brokerid" name="brokerid"
                                                                     value="{{ brokerid }}" type="text"
                                                                     placeholder="请输入BrokerID<必填字段>" minlength="2"></h5>
                <h5><p style="margin-left:20px">*</p>userID:&nbsp&nbsp&nbsp<input id="userid" name="userid"
                                                                                  value="{{ userid }}" type="text"
                                                                                  placeholder="请输入userID<必填字段>"
                                                                                  minlength="4"></h5>
                <h5><p style="margin-left:20px">*</p>&nbsp&nbsp&nbsp password:&nbsp
                    <input name="paaswordtrader" type="password" value="{{ passwordtrader }}" placeholder="请输入密码<必填字段>"
                           id="pass" maxlength="16" class="pass">
                    <label class="" onclick="change()" style="margin-top:20px"><img src="{% static 'images/eye.png' %}"></label>
                </h5>
            </div>
        </div>
        <div onkeydown="keyLogin();">
            <input type="submit" id="" class="new" value="更新信息">
            &nbsp&nbsp&nbsp&nbsp
            <label style="color: red">{{ msg }}</label>
        </div>
    </form>
</div>
<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript">
    function validateForm() {
        if (document.user_s.brokerid.value == "") {
            alert("请填写BrokerId！");
            document.user_s.brokerid.focus();
            return false;
        } else if (document.user_s.userid.value == "") {
            alert("请填写UserId！");
            document.user_s.userid.focus();
            return false;
        } else if (document.user_s.paaswordtrader.value == "") {
            alert("请填写密码！");
            document.user_s.paaswordtrader.focus();
            return false;
        } else if (document.user_s.mobile.value == "") {
            alert("请填写联系电话!");
            document.user_s.mobile.focus();
            return false;
        }
        return true;
    }
</script>


<script>
    //这里是关键点 .ready 函数好像监听器。
    window.onload = function () {
        //jq的处理函数，当点击提交按钮时执行。

        var user_per = $("#username_per").val();
        var password_per = $("#password_per").val();
//向服务器发送get请求，请求地址为/ajax_data/
        $.get("/ajax_data/", {
            'user_per': user_per,
            'password_per': password_per,

        }, function (ret) {

            $('#nickname').attr("value", ret['nickname'])
            $('#gender').attr("value", ret['gender'])
            $('#mobile').attr("value", ret['mobile'])
            $('#address').attr("value", ret['address'])
            $('#brokerid').attr("value", ret['brokerid'])
            $('#userid').attr("value", ret['userid'])
            $('#pass').attr("value", ret['pass'])
        })
    }


</script>


</body>
</html>